package mvp.com.bbc.rcjavaretrofitdaggermvp.app.utils;

/**
 * Created by cbf on 2017/11/24.
 */

import android.app.Activity;
import com.umeng.socialize.ShareAction;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.media.UMImage;
import com.umeng.socialize.media.UMWeb;
import mvp.com.bbc.rcjavaretrofitdaggermvp.R;
import mvp.com.bbc.rcjavaretrofitdaggermvp.app.BaseApplication;

/**
 * 分享的工具类
 */
public class ShareUtils {
    public static void shareWeb(Activity act, String url, String title, String description) {
        if (url == null) {
            return;
        }
        UMWeb web = new UMWeb(url);
        if (title != null && description != null) {
            web.setTitle(title);//设置标题
            web.setDescription(description);//设置描述
        }
        web.setThumb(new UMImage(BaseApplication.getContext(), R.mipmap.ic_launcher));
        new ShareAction(act).withMedia(web)
                .setDisplayList(SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE, SHARE_MEDIA.WEIXIN_FAVORITE, SHARE_MEDIA.SINA,
                        SHARE_MEDIA.QQ, SHARE_MEDIA.QZONE, SHARE_MEDIA.TENCENT)
                .setCallback(new CustomUMShareListener(act)).open();
    }
}
